#include "apue.2e/include/apue.h"

#define BUFFSIZE 4096

// usage
// ./a.out
// ./a.out > abc.txt
// ./a.out < abc.txt > foo.txt
int main(void)
{
	int n;
	char buf[BUFFSIZE];

	while ((n=read(STDIN_FILENO, buf, BUFFSIZE))>0)
		if(write(STDOUT_FILENO,buf,n)!=n)
			err_sys("write error");

	exit(0);
}

/**
http://linux.die.net/man/3/read

<unistd.h>中包含了 STDIN_FILENO,STDOUT_FILENO
ssize_t read(int fildes, void *buf, size_t nbyte);
attempt to read nbyte bytes
from the file associated with the open file descriptor, fildes,
into the buffer pointed to by buf

*/
